
export interface IStorage {
    loadString(key: string): string | undefined;
    saveString(key: string, value: string): boolean;
  
    loadObject(key: string): object | undefined;
    saveObject(key: string, value: object): boolean;
  
    has(key: string): boolean;
    delete(key: string): string | object;
    clear(): boolean;
    size(): number;
  }
  
  
  export abstract class AbstractStorage implements IStorage {
    protected namespace: string;
    constructor(namespace: string) {
      this.namespace = namespace + ':';
    }
  
    abstract implLoadString(key: string): string | undefined;
    abstract implSaveString(key: string, value: string): boolean;
    abstract implLoadObject(key: string): object | undefined;
    abstract implSaveObject(key: string, value: object): boolean;
    abstract implHas(key: string): boolean;
    abstract implDelete(key:string): string | object | undefined;
  
    loadString(key: string): string | undefined {
      return this.implLoadString(this.namespace + key);
    }
  
    saveString(key: string, value: string): boolean {
      return this.implSaveString(this.namespace + key, value);
    }
  
    loadObject(key: string): object {
      return this.implLoadObject(this.namespace + key); 
    }
  
    saveObject(key: string, value: object): boolean {
      return this.implSaveObject(this.namespace + key, value);
    }

    has(key: string): boolean {
      return this.implHas(this.namespace + key);
    }
  
    delete(key: string): string | object | undefined {
      return this.implDelete(this.namespace + key);
    }
  }

